]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
swipeTracker: Reject touchpad swipes in the wrong directions
authorFlorian Müllner <fmuellner@gnome.org>
Tue, 9 Jun 2020 23:45:08 +0000 (01:45 +0200)
committerCarlos Garnacho <carlosg@gnome.org>
Wed, 17 Feb 2021 13:06:11 +0000 (14:06 +0100)
We now have multiple touch swipe gestures with matching fingers and
different directions set on the overview hierarchy. Accepting all
touchpad swipes without checking the direction makes one of these gestures
take control of input, without other gestures having a say on this.

So, look for the direction of the swipe events and look if it matches
the expected orientation.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1643>

js/ui/swipeTracker.js

index 7bd4a96bd7261f06ce6eab72e097114a9774ada1..5bc2c49e4816ca489dc208f3a99df464492dfbe8 100644 (file)
@@ -124,6 +124,17 @@ const TouchpadSwipeGesture = GObject.registerClass({
         let [x, y] = event.get_coords();
         let [dx, dy] = event.get_gesture_motion_delta();
 
+        let gestureOrientation = -1;
+        if (dx !== dy) {
+            gestureOrientation = Math.abs(dx) > Math.abs(dy)
+                ? Clutter.Orientation.HORIZONTAL
+                : Clutter.Orientation.VERTICAL;
+        }
+
+        if (gestureOrientation >= 0 &&
+            gestureOrientation !== this.orientation)
+            return Clutter.EVENT_PROPAGATE;
+
         const vertical = this.orientation === Clutter.Orientation.VERTICAL;
         let delta = (vertical ? dy : dx) * SWIPE_MULTIPLIER;
         const distance = vertical ? TOUCHPAD_BASE_HEIGHT : TOUCHPAD_BASE_WIDTH;
@@ -146,7 +157,9 @@ const TouchpadSwipeGesture = GObject.registerClass({
             break;
         }
 
-        return Clutter.EVENT_STOP;
+        return gestureOrientation === this.orientation
+            ? Clutter.EVENT_STOP
+            : Clutter.EVENT_PROPAGATE;
     }
 
     destroy() {